import { dataQueryAxios, datashopAxios } from '@/utils/request'

// 列表
export const getSettingDataItemList = (params: any): Promise<any> => {
  return dataQueryAxios({
    url: `/api/data-query/v1/release-items`,
    method: 'get',
    params
  })
}

// 数据项发布
export const publishDataItem = (data: any): Promise<any> => {
  return dataQueryAxios({
    url: `/api/data-query/v1/release-items/${data.id}:publish`,
    method: 'post',
    data
  })
}

// 数据项下线
export const offlineDataItem = (data: any): Promise<any> => {
  return dataQueryAxios({
    url: `/api/data-query/v1/release-items/${data.id}:offline`,
    method: 'post',
    data
  })
}

// 筛选配置相关
// 规格列表
export const getDataItemSettingList = (params: any): Promise<any> => {
  return dataQueryAxios({
    url: `/api/data-query/v1/release-items/${params.release_item_id}/filters`,
    method: 'get',
    params
  })
}
// 新增
export const addDataItemSetting = (data: any): Promise<any> => {
  return dataQueryAxios({
    url: `/api/data-query/v1/release-items/${data.release_item_id}/filters`,
    method: 'post',
    data
  })
}
// 编辑
export const editDataItemSetting = (data: any): Promise<any> => {
  return dataQueryAxios({
    url: `/api/data-query/v1/release-items/${data.release_item_id}/filters/${data.id}`,
    method: 'put',
    data
  })
}
// 删除
export const deleteDataItemSetting = (data: any): Promise<any> => {
  return dataQueryAxios({
    url: `/api/data-query/v1/release-items/${data.release_item_id}/filters/${data.id}`,
    method: 'delete'
  })
}

// 聚合筛选项选项值
export const getDataItemPolymerizeOptions = (params: any): Promise<any> => {
  return dataQueryAxios({
    url: `/api/data-query/v1/release-items/${params.release_item_id}/filters/polymerize-option`,
    method: 'get',
    params
  })
}

// 关联关系项列表
export const getRelationDataItemList = (params: any): Promise<any> => {
  return dataQueryAxios({
    url: `/api/data-query/v1/release-items/${params.release_item_id}/relations`,
    method: 'get',
    params
  })
}
// 创建关联关系项
export const addRelationDataItem = (data: any): Promise<any> => {
  return dataQueryAxios({
    url: `/api/data-query/v1/release-items/${data.release_item_id}/relations`,
    method: 'post',
    data
  })
}
// 更新关联关系项
export const editRelationDataItem = (data: any): Promise<any> => {
  return dataQueryAxios({
    url: `/api/data-query/v1/release-items/${data.release_item_id}/relations/${data.id}`,
    method: 'put',
    data
  })
}
// 删除关联关系项
export const deleteRelationDataItem = (data: any): Promise<any> => {
  return dataQueryAxios({
    url: `/api/data-query/v1/release-items/${data.release_item_id}/relations/${data.id}`,
    method: 'delete',
    data
  })
}

//排序规则列表
export const getDataItemSortList = (params: any): Promise<any> => {
  return dataQueryAxios({
    url: `/api/data-query/v1/release-items/${params.release_item_id}/sort_rules`,
    method: 'get',
    params
  })
}
// 创建排序规则
export const addDataItemSort = (data: any): Promise<any> => {
  return dataQueryAxios({
    url: `/api/data-query/v1/release-items/${data.release_item_id}/sort_rules`,
    method: 'post',
    data
  })
}
// 更新排序规则
export const editDataItemSort = (data: any): Promise<any> => {
  return dataQueryAxios({
    url: `/api/data-query/v1/release-items/${data.release_item_id}/sort_rules/${data.id}`,
    method: 'put',
    data
  })
}
// 删除排序规则
export const deleteDataItemSort = (data: any): Promise<any> => {
  return dataQueryAxios({
    url: `/api/data-query/v1/release-items/${data.release_item_id}/sort_rules/${data.id}`,
    method: 'delete',
    data
  })
}

//详情分组列表
export const getDataItemGroupList = (params: any): Promise<any> => {
  return datashopAxios({
    url: `/api/datashop/v4/column-groups`,
    method: 'get',
    params
  })
}
// 创建数据产品字段组
export const addDataItemGroup = (data: any): Promise<any> => {
  return datashopAxios({
    url: `/api/datashop/v4/column-groups`,
    method: 'post',
    data
  })
}
// 更新数据产品字段组
export const updateDataItemGroup = (data: any): Promise<any> => {
  return datashopAxios({
    url: `/api/datashop/v4/column-groups/${data.pk}`,
    method: 'put',
    data
  })
}
// 删除数据产品字段组
export const deleteDataItemGroup = (data: any): Promise<any> => {
  return datashopAxios({
    url: `/api/datashop/v4/column-groups/${data.pk}`,
    method: 'delete',
    data
  })
}
